_mmmm_mmmm_aaaa_pppp establishes a mapping between the process's address space at an
address _p_a for _l_e_n bytes to the memory object represented by the file
descriptor _f_d at offset _o_f_f for _l_e_n bytes. The value of _p_a is an
implementation-dependent function of the parameter _a_d_d_r and values of
_f_l_a_g_s, further described below. A successful _mmmm_mmmm_aaaa_pppp call returns _p_a as its
result. The address ranges covered by [_p_a, _p_a + _l_e_n) and [_o_f_f, _o_f_f +
_l_e_n) must be legitimate for the possible (not necessarily current)
address space of a process and the object in question, respectively.
The only difference between _mmmm_mmmm_aaaa_pppp and _mmmm_mmmm_aaaa_pppp_6666_4444 is that in _mmmm_mmmm_aaaa_pppp_6666_4444 the _o_f_f
parameter is 64 bits long, so the file offset can be greater than 2
gigabytes. This is useful for certain filesystem types that support such
file offsets.
The mapping established by _mmmm_mmmm_aaaa_pppp replaces any previous mappings for the
process's pages in the range [_p_a, _p_a + _l_e_n).
The parameter _p_r_o_t determines whether read (load), write (store),
execute, or some combination of accesses are permitted to the pages being
mapped. The protection options are defined in _<<<<_ssss_yyyy_ssss_////_mmmm_mmmm_aaaa_nnnn_...._hhhh_>>>> as:
_PPPP_RRRR_OOOO_TTTT______RRRR_EEEE_AAAA_DDDD Page can be read.
_PPPP_RRRR_OOOO_TTTT______WWWW_RRRR_IIII_TTTT_EEEE Page can be written.
_PPPP_RRRR_OOOO_TTTT______EEEE_XXXX_EEEE_CCCC Page can be executed.
_PPPP_RRRR_OOOO_TTTT______NNNN_OOOO_NNNN_EEEE Page can not be accessed.
Not all implementations literally provide all possible combinations.
_PPPP_RRRR_OOOO_TTTT______WWWW_RRRR_IIII_TTTT_EEEE is often implemented as _PPPP_RRRR_OOOO_TTTT______RRRR_EEEE_AAAA_DDDD_||||_PPPP_RRRR_OOOO_TTTT______WWWW_RRRR_IIII_TTTT_EEEE and _PPPP_RRRR_OOOO_TTTT______EEEE_XXXX_EEEE_CCCC as
_PPPP_RRRR_OOOO_TTTT______RRRR_EEEE_AAAA_DDDD_||||_PPPP_RRRR_OOOO_TTTT______EEEE_XXXX_EEEE_CCCC. This is true for all SGI implementations. In
particular, MIPS processors do not support a separate execute permission.
Any page that can be read can be executed from, even if _PPPP_RRRR_OOOO_TTTT______EEEE_XXXX_EEEE_CCCC is not
specified. Instead, the operating system uses _PPPP_RRRR_OOOO_TTTT______EEEE_XXXX_EEEE_CCCC as a flag to
indicate it may need to perform certain platform dependent functions
_MMMM_AAAA_PPPP______LLLL_OOOO_CCCC_AAAA_LLLL Do not share with share group
_MMMM_AAAA_PPPP______AAAA_UUUU_TTTT_OOOO_RRRR_EEEE_SSSS_RRRR_VVVV Reserve logical swap on demand
_MMMM_AAAA_PPPP______SSSS_GGGG_IIII______AAAA_NNNN_YYYY_AAAA_DDDD_DDDD_RRRR Use reserved area for mappings
_MMMM_AAAA_PPPP______SSSS_HHHH_AAAA_RRRR_EEEE_DDDD and _MMMM_AAAA_PPPP______PPPP_RRRR_IIII_VVVV_AAAA_TTTT_EEEE describe the disposition of store references
to the memory object. If _MMMM_AAAA_PPPP______SSSS_HHHH_AAAA_RRRR_EEEE_DDDD is specified, store references will
change the memory object. If _MMMM_AAAA_PPPP______PPPP_RRRR_IIII_VVVV_AAAA_TTTT_EEEE is specified, the initial store
reference will create a private copy of the memory object page and
redirect the mapping to the copy. Either _MMMM_AAAA_PPPP______SSSS_HHHH_AAAA_RRRR_EEEE_DDDD or _MMMM_AAAA_PPPP______PPPP_RRRR_IIII_VVVV_AAAA_TTTT_EEEE must
be specified, but not both. The mapping type is retained across a
_ffff_oooo_rrrr_kkkk(2).
When _MMMM_AAAA_PPPP______SSSS_HHHH_AAAA_RRRR_EEEE_DDDD is specified, and initially in all pages when _MMMM_AAAA_PPPP______PPPP_RRRR_IIII_VVVV_AAAA_TTTT_EEEE
is specified, the contents of the mapped segment change to reflect
changes in the underlying memory object. Changes can be caused by other
processes that map the same object with _MMMM_AAAA_PPPP______SSSS_HHHH_AAAA_RRRR_EEEE_DDDD, or by processes using
write(2) or ftruncate(2). If the file is shortened, an attempt to access
a page of memory that is mapped to a part of the file that no longer
exists will cause a Bus Error (SIGBUS) signal.
When _MMMM_AAAA_PPPP______PPPP_RRRR_IIII_VVVV_AAAA_TTTT_EEEE is used, a private copy of a page is created only when
the process stores into the page. This prevents changes from being seen
by other processes that map the same object, and prevents further changes
made by other processes from being visible. However, changes that occur
before the page is stored into are visible.
To protect the contents of a mapped file from changes or truncation you
can either use chmod(2) and lockf(3) to enforce a mandatory file lock, or
you can specify _MMMM_AAAA_PPPP______PPPP_RRRR_IIII_VVVV_AAAA_TTTT_EEEE and store into every page of the segment in
order to create a complete private copy of the data.
_MMMM_AAAA_PPPP______FFFF_IIII_XXXX_EEEE_DDDD informs the system that the value of _p_a must be _a_d_d_r, exactly.
When _MMMM_AAAA_PPPP______FFFF_IIII_XXXX_EEEE_DDDD is not set, the system uses _a_d_d_r in an implementation-
specific manner to arrive at _p_a. The _p_a so chosen will be an area of the
address space which the system deems suitable for a mapping of _l_e_n bytes
All implementations interpret an _a_d_d_r value of zero as granting the
system complete freedom in selecting _p_a, subject to constraints described
below. A non-zero value of _a_d_d_r is taken to be a suggestion of a process
address near which the mapping should be placed. When the system selects
a value for _p_a, it will never place a mapping at address _0000, nor will it
replace any extant mapping, and it will attempt to map away from areas
considered part of the potential data or stack segments.
The _MMMM_AAAA_PPPP______FFFF_IIII_XXXX_EEEE_DDDD directive should be used with caution. When _MMMM_AAAA_PPPP______FFFF_IIII_XXXX_EEEE_DDDD is
set, any mappings (including text, heap, data, and stack) in the range
[_a_d_d_r, _a_d_d_r + _l_e_n) will be replaced with the new mapping.
To ensure best system hardware cache behavior, objects should be mapped
such that the low sixteen bits of the file offset of the object match the
low bits of the mapped address.
The address range from 0x30000000 to 0x40000000 is normally reserved for
_MMMM_AAAA_PPPP______FFFF_IIII_XXXX_EEEE_DDDD mappings except when _MMMM_AAAA_PPPP______SSSS_GGGG_IIII______AAAA_NNNN_YYYY_AAAA_DDDD_DDDD_RRRR is specified or when the
_SSSS_GGGG_IIII______UUUU_NNNN_SSSS_UUUU_PPPP_PPPP_OOOO_RRRR_TTTT_EEEE_DDDD______MMMM_AAAA_PPPP______RRRR_EEEE_SSSS_EEEE_RRRR_VVVV_EEEE_DDDD______RRRR_AAAA_NNNN_GGGG_EEEE option is enabled with _ssss_yyyy_ssss_ssss_gggg_iiii(2).
Note that this space may not be useful for programs which require a very
large heap, since by default program heaps start near 0x10000000 and grow
toward higher addresses. This range will never be used when zero is
passed as the value for _a_d_d_r unless either _MMMM_AAAA_PPPP______SSSS_GGGG_IIII______AAAA_NNNN_YYYY_AAAA_DDDD_DDDD_RRRR or
_SSSS_GGGG_IIII______UUUU_NNNN_SSSS_UUUU_PPPP_PPPP_OOOO_RRRR_TTTT_EEEE_DDDD______MMMM_AAAA_PPPP______RRRR_EEEE_SSSS_EEEE_RRRR_VVVV_EEEE_DDDD______RRRR_AAAA_NNNN_GGGG_EEEE is used. See _ssss_gggg_iiii______uuuu_ssss_eeee______aaaa_nnnn_yyyy_aaaa_dddd_dddd_rrrr(1) for
further details.
If _MMMM_AAAA_PPPP______AAAA_UUUU_TTTT_OOOO_GGGG_RRRR_OOOO_WWWW is specified with _MMMM_AAAA_PPPP______SSSS_HHHH_AAAA_RRRR_EEEE_DDDD, the mapped object will be
implicitly grown when referenced by a store operation to a page which
maps beyond the current end of the object; the object will be grown and
zero-filled to fulfill the mapping up to the next page boundary or to the
end of the mapping, whichever is less. If used with _MMMM_AAAA_PPPP______PPPP_RRRR_IIII_VVVV_AAAA_TTTT_EEEE,
_MMMM_AAAA_PPPP______AAAA_UUUU_TTTT_OOOO_GGGG_RRRR_OOOO_WWWW allocates private zero-filled pages for references beyond
the end of the object, but does not grow the object.
_MMMM_AAAA_PPPP______AAAA_UUUU_TTTT_OOOO_GGGG_RRRR_OOOO_WWWW requires that the object is mapped with _PPPP_RRRR_OOOO_TTTT______WWWW_RRRR_IIII_TTTT_EEEE
permission. Load references to mapped pages following the end of a
object will result in the delivery of a _SSSS_IIII_GGGG_SSSS_EEEE_GGGG_VVVV signal, as will various
filesystem conditions on stores. Whenever a _SSSS_IIII_GGGG_SSSS_EEEE_GGGG_VVVV signal is delivered,
the second argument to the signal handler contains a value that indicates
the reason for the delivery of the signal; these values are defined in
/_u_s_r/_i_n_c_l_u_d_e/_s_y_s/_e_r_r_n_o._h.
When _MMMM_AAAA_PPPP______AAAA_UUUU_TTTT_OOOO_GGGG_RRRR_OOOO_WWWW is specified, _l_e_n determines the maximum size of the
memory map, as opposed to the initial size. The size of the map is
extended automatically by storing to any location beyond the current
working size, up to the size limited by _l_e_n. The mapped file will also be
extended, even if it is closed. Any read or write beyond the end of the
_l_e_n specified area results in delivery of a _SSSS_IIII_GGGG_SSSS_EEEE_GGGG_VVVV signal. Therefore
the use of _MMMM_AAAA_PPPP______AAAA_UUUU_TTTT_OOOO_GGGG_RRRR_OOOO_WWWW must anticipate the maximum _l_e_n as to prevent
failed accesses beyond the end of the mmapped area.
If _MMMM_AAAA_PPPP______LLLL_OOOO_CCCC_AAAA_LLLL is used and the process does an _s_p_r_o_c(2) each process will
receive a private copy of the object's mapping. All subsequent load
reference of objects mapped _MMMM_AAAA_PPPP______PPPP_RRRR_IIII_VVVV_AAAA_TTTT_EEEE will cause private copies of the
object to be created. In addition, the share group processes will be
able to independently unmap the object from their address spaces.
The system reserves _l_e_n bytes of logical swap space when _MMMM_AAAA_PPPP______PPPP_RRRR_IIII_VVVV_AAAA_TTTT_EEEE
mappings of regular files are created, as well as for all mappings of
/dev/zero. (See _ssss_wwww_aaaa_pppp_((((_1111_mmmm_)))) for a discussion of logical swap space.) If
insufficient logical swap space is available, _mmmm_mmmm_aaaa_pppp fails with _EEEE_AAAA_GGGG_AAAA_IIII_NNNN.
The _MMMM_AAAA_PPPP______AAAA_UUUU_TTTT_OOOO_RRRR_EEEE_SSSS_RRRR_VVVV flag causes logical swap space to be automatically
reserved as each page is first referenced with a store operation instead
of when the mapping is created. When this flag is used, no logical swap
space is reserved when the mapping is created. Therefore, the system
cannot guarantee that space will be available when needed. If all the
logical swap space has been taken by other processes when a page in a
_MMMM_AAAA_PPPP______AAAA_UUUU_TTTT_OOOO_RRRR_EEEE_SSSS_RRRR_VVVV mapping is first stored to, then the process will be sent
_SSSS_IIII_GGGG_BBBB_UUUU_SSSS.
The parameter _o_f_f is constrained to be aligned and sized according to the
value returned by _gggg_eeee_tttt_pppp_aaaa_gggg_eeee_ssss_iiii_zzzz_eeee_((((_2222_)))) or _ssss_yyyy_ssss_cccc_oooo_nnnn_ffff(_SC_PAGESIZE). When
_MMMM_AAAA_PPPP______FFFF_IIII_XXXX_EEEE_DDDD is specified, the parameter _a_d_d_r as well as _o_f_f must be aligned
according to the value returned by _ssss_yyyy_ssss_cccc_oooo_nnnn_ffff(_SC_MMAP_FIXED_ALIGNMENT).
The system performs mapping operations over whole pages. Thus, while the
parameter _l_e_n need not meet a size or alignment constraint, the system
will include, in any mapping operation, any partial page specified by the
range [_p_a, _p_a + _l_e_n).
The system will always zero-fill any partial page at the end of an
object. Further, the system will never write out any modified portions
of the last page of an object which are beyond its end. References to
whole pages following the end of an object will result in the delivery of
a _SSSS_IIII_GGGG_BBBB_UUUU_SSSS signal. _SSSS_IIII_GGGG_BBBB_UUUU_SSSS signals may also be delivered on various
filesystem conditions, including quota exceeded errors, and for physical
device errors (such as unreadable disk blocks). The signal handler may
examine the _ssss_iiii______cccc_oooo_dddd_eeee and _ssss_iiii______eeee_rrrr_rrrr_nnnn_oooo fields of the _ssss_iiii_gggg_iiii_nnnn_ffff_oooo structure for
information about the nature of the error.
RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEE
On success, _mmmm_mmmm_aaaa_pppp returns the address at which the mapping was placed
(_p_a). On failure it returns _MMMM_AAAA_PPPP______FFFF_AAAA_IIII_LLLL_EEEE_DDDD and sets _eeee_rrrr_rrrr_nnnn_oooo to indicate an
error.
EEEERRRRRRRROOOORRRRSSSS
Under the following conditions, _mmmm_mmmm_aaaa_pppp fails and sets _eeee_rrrr_rrrr_nnnn_oooo to:
_EEEE_AAAA_GGGG_AAAA_IIII_NNNN The mapping could not be locked in memory.
_EEEE_AAAA_GGGG_AAAA_IIII_NNNN The amount of logical swap space required is temporarily